package crud.client.data;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;

import com.google.gwt.user.client.rpc.IsSerializable;

import crud.client.annotation.FormItemFactory;
import crud.client.annotation.Label;
import crud.client.factory.form.DateFormItemNoDatePickerFactory;

@Entity(name = "SOCIETE")
public class Societe implements Serializable, IsSerializable
{
	@Id
	@Column(name = "SOCIETE_ID")
	@Label(value = "Identifiant")
	private Integer societeId;

	@Column(name = "NOM", length = 20)
	@Label(value = "Nom de la société")
	private String nom;

	@Column(name = "CHIFFRE_AFFAIRE")
	@Label(value = "Chiffre d'affaire")
	private Float chiffreAffaire;

	@Column(name = "NOMBRE_SALARIE")
	@Label(value = "Nombre salarié")
	private Long nombreSalarie;

	@Column(name = "DATE_CREATION")
	@Label(value = "Date création")
	@FormItemFactory(factory = DateFormItemNoDatePickerFactory.class)
	private Date dateCreation;

	public Integer getSocieteId()
	{
		return societeId;
	}

	public void setSocieteId(Integer societeId)
	{
		this.societeId = societeId;
	}

	public String getNom()
	{
		return nom;
	}

	public void setNom(String nom)
	{
		this.nom = nom;
	}

	@Override
	public int hashCode()
	{
		return societeId;
	}

	public Float getChiffreAffaire()
	{
		return chiffreAffaire;
	}

	public void setChiffreAffaire(Float chiffreAffaire)
	{
		this.chiffreAffaire = chiffreAffaire;
	}

	public Long getNombreSalarie()
	{
		return nombreSalarie;
	}

	public void setNombreSalarie(Long nombreSalarie)
	{
		this.nombreSalarie = nombreSalarie;
	}

	public Date getDateCreation()
	{
		return dateCreation;
	}

	public void setDateCreation(Date dateCreation)
	{
		this.dateCreation = dateCreation;
	}

	@Override
	public boolean equals(Object obj)
	{
		if (obj == null || !(obj instanceof Societe))
		{
			return false;
		}

		return societeId.equals(((Societe) obj).getSocieteId());
	}

}
